package com.eco.fanliapp.controller.app;


import com.eco.fanliapp.common.base.BaseController;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.entity.AppUser;
import com.eco.fanliapp.service.ISyChannelUserService;
import com.eco.fanliapp.service.ISyTljGoodsfreeService;
import com.eco.fanliapp.service.impl.SyTljGoodsfreeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 淘礼金免单商品 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-11-27
 */
@RestController
@RequestMapping("/app/module")
public class SyTljGoodsfreeController extends BaseController {
    @Autowired
    private ISyTljGoodsfreeService syTljGoodsfreeService;

    /**
     * 0元购淘礼金商品
     * @return
     */
    @GetMapping(value = "/zeroBuy/details")
    public ServerResponse zeroBuyDetails(HttpServletRequest request){
        String version = request.getHeader("version");
        AppUser user= getAppUser();
        if(user != null && user.getUserId() != null){
            return syTljGoodsfreeService.zeroBuyDetails(user.getUserId(),version);
        }
        return syTljGoodsfreeService.zeroBuyDetails(null,version);
    }

    /**
     * 限时漏洞商品
     * @return
     */
    @GetMapping(value = "/loophole/details")
    public ServerResponse loopholeDetails(HttpServletRequest request){
        String version = request.getHeader("version");
        AppUser user= getAppUser();
        if(user != null && user.getUserId() != null){
            return syTljGoodsfreeService.loopholeDetails(user.getUserId(),version);
        }
        return syTljGoodsfreeService.loopholeDetails(null,version);
    }

}
